package com.sptpc.learnspring.controller.customer;

import com.sptpc.learnspring.model.Order;
import com.sptpc.learnspring.service.IOrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class DrinkBrewCustomer {
    @Autowired
    private IOrderService orderService;

    // 模拟调饮师收到支付订单后的操作
    @RabbitListener(queues = "paid-order")
    public void brewDrink(Long orderId) {
        Order order = orderService.getOrder(orderId);
        log.info("调饮师收到订单:{}", order);
        log.info("调饮师完成订单制作");
        // state 2 - 制作完成
        orderService.updateState(order, 2);
    }
}
